package com.nuanshui.heatedloan.model;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.nuanshui.heatedloan.dal.BaseEntityImpl;

public class DiscountCoupon extends BaseEntityImpl {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private String userId;//生成优惠券的用户 
	
	private String code;//优惠券编码
	private Date createdAt;//生成时间
	private Integer userCount;//如果为-1表示没有用户限制
	private Integer price;//价格
	private Long expireTime;//优惠券的有效期 
    private Integer userNum;//可以有多少人获取次红包 如果是优惠券,则表示总共有多少张
	private Integer type;//优惠券类型  1表示 邀请红包 2表示红包（官方券） 3表示优惠券 
	private String nick;//用户昵称
	private String acceptNick;//获取的优惠券的昵称
    private Integer totalPrice;//总价
    private Integer generatePriceType;//红包面额生成类型 1表示固定  2表示随机

    
    private String shareTitle;//分享出去时的描述
    
    private String shareDes;//分享出去时的描述
    
    private String title;//修改标题
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date availableTime; //优惠券生效日期
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Long couponExpireTime;		//红包过期时间
    
    private Integer couponThreshold;	//优惠券使用门槛  数值为 0 则表示无门槛
    
    private Integer couponStatus;	//优惠券的上架状态 未上架 1  上架 2   平台券状态为空
    private Integer receivedCount; 	//优惠券的领取数量
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date couponExpireDate;	//优惠券失效日期
	
	private Integer isReceived;		 //判断用户是否已经领取该优惠券  	0表示未领取  1表示已经领取
	
    public static final int isReceived_NO=0;			//未领取
    public static final int isReceived_YES=1;			//已领取
	
    
    /**
     * 未上架  1
     */
    public static final int COUPONSTATUS_NOTONSHELVE=1;
    /**
     * 已上架 2
     */
    public static final int COUPONSTATUS_ONSHELVE=2;
    /**
     * 优惠券已过期
     */
    public static final int COUPONSTATUS_EXPIRED=3;
    
    
    
    
	public Long getCouponExpireTime() {
		return couponExpireTime;
	}
	public void setCouponExpireTime(Long couponExpireTime) {
		this.couponExpireTime = couponExpireTime;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Integer getGeneratePriceType() {
		return generatePriceType;
	}
	public void setGeneratePriceType(Integer generatePriceType) {
		this.generatePriceType = generatePriceType;
	}
	public String getShareTitle() {
		return shareTitle;
	}
	public void setShareTitle(String shareTitle) {
		this.shareTitle = shareTitle;
	}
	public String getShareDes() {
		return shareDes;
	}
	public void setShareDes(String shareDes) {
		this.shareDes = shareDes;
	}
	public Integer getTotalPrice() {
		return totalPrice;
	}
	public void setTotalPrice(Integer totalPrice) {
		this.totalPrice = totalPrice;
	}
	public Integer getUserNum() {
		return userNum;
	}
	public void setUserNum(Integer userNum) {
		this.userNum = userNum;
	}
	public Long getExpireTime() {
		return expireTime;
	}
	public void setExpireTime(Long expireTime) {
		this.expireTime = expireTime;
	}
	public String getAcceptNick() {
		return acceptNick;
	}
	public void setAcceptNick(String acceptNick) {
		this.acceptNick = acceptNick;
	}
	public String getNick() {
		return nick;
	}
	public void setNick(String nick) {
		this.nick = nick;
	}
	public Integer getType() {
		return type;
	}
	public void setType(Integer type) {
		this.type = type;
	}
	public Integer getPrice() {
		return price;
	}
	public void setPrice(Integer price) {
		this.price = price;
	}
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public Date getCreatedAt() {
		return createdAt;
	}
	public void setCreatedAt(Date createdAt) {
		this.createdAt = createdAt;
	}
	public Integer getUserCount() {
		return userCount;
	}
	public void setUserCount(Integer userCount) {
		this.userCount = userCount;
	}
	
	//是否有效
	public boolean getIsValid() {
		if(couponExpireTime == null) return true;
		return (System.currentTimeMillis()-createdAt.getTime())<=couponExpireTime;		
	}
	
	public Integer getCouponThreshold() {
		return couponThreshold;
	}
	public void setCouponThreshold(Integer couponThreshold) {
		this.couponThreshold = couponThreshold;
	}
	public Date getAvailableTime() {
		return availableTime;
	}
	public void setAvailableTime(Date availableTime) {
		this.availableTime = availableTime;
	}
	public Integer getCouponStatus() {
		return couponStatus;
	}
	public void setCouponStatus(Integer couponStatus) {
		this.couponStatus = couponStatus;
	}
	public Integer getReceivedCount() {
		return receivedCount;
	}
	public void setReceivedCount(Integer receivedCount) {
		this.receivedCount = receivedCount;
	}
	public Date getCouponExpireDate() {
		return couponExpireDate;
	}
	public void setCouponExpireDate(Date couponExpireDate) {
		this.couponExpireDate = couponExpireDate;
	}
	/**
	 * @return Returns the isReceived.
	 */
	public Integer getIsReceived() {
		return isReceived;
	}
	/**
	 * @param isReceived The isReceived to set.
	 */
	public void setIsReceived(Integer isReceived) {
		this.isReceived = isReceived;
	}

	
}
